<template>
  <!--求职意向-->
  <view>
    <my-head
      title="求职意向"
      :right="true"
      text_right="添加"
      bold="false"
      @clickRight="clickRight"
    ></my-head>
    <template v-for="(item, index) in qiuzhiyixiangData">
      <view
        :key="index"
        v-if="qiuzhiyixiangData.length > 0"
        class="swipeAction"
        :style="{ marginTop: index == 0 ? '6rpx' : '' }"
      >
        <view class="jiaonliguanli">
          <view class="edit_data">
            <view class="item_box">
              <view class="fl-w pinfen">
                <view class="position">{{ item.PositionName }}</view>
                <view class="p_data" v-if="!item.Negotiable">
                  {{ item.MinWage / 1000 }}K~{{ item.MaxWage / 1000 }}K
                </view>
                <view class="p_data" v-if="item.Negotiable">{{
                  item.Negotiable ? "面议" : ""
                }}</view>
                <view class="p_data">
                  {{
                    item.WorkType == 0
                      ? "全职"
                      : item.WorkType == 1
                      ? "兼职"
                      : item.WorkType == 2
                      ? "实习"
                      : ""
                  }}
                </view>
                <view class="p_data">{{ item.PcaAddress }}</view>
              </view>
              <view class="fl-w tagBox">
                <view
                  class="job_type"
                  v-for="(itt, index) in item.IndustryList"
                  :key="index"
                >
                  {{ itt.Name }}
                </view>
              </view>
            </view>
            <view class="dlsdflex">
              <view style="padding-right: 40rpx">
                <image
                  src="/static/image/zwgl/bianji.png"
                  @click="clickRight(2, item)"
                  style="width: 26rpx; height: 26rpx"
                ></image>
              </view>
              <view>
                <image
                  src="/static/image/zwgl/sc.png"
                  @click.stop="handleXingqu(item)"
                  style="width: 26rpx; height: 26rpx"
                ></image>
              </view>
            </view>
          </view>
        </view>
      </view>
    </template>
    <!-- 暂无数据页面 -->
    <view class="queshenye" v-if="qiuzhiyixiangData.length == 0">
      <view class="queshenye-chi">
        <view style="padding-top: 30%">
          <image src="/static/image/queshengye.png"></image>
        </view>
        <view>暂无数据</view>
      </view>
    </view>
    <u-modal
      :show="show"
      title="确认删除"
      :content="content"
      :showCancelButton="true"
      @confirm="confirm()"
      @cancel="show = false"
    ></u-modal>
  </view>
</template>

<script>
import myHead from "@/pages/component/baseHead.vue";
export default {
  data() {
    return {
      show: false,
      content: "",
      id: "",
      list: "",
      load: false, //是否加载到数据
      type: null,
      qiuzhiyixiangData: [], //求职意向栏
      miaoshuData: [], //描述关键字
      ResumeId: "",
      value: [
        {
          name: "全选",
          disabled: false,
        },
      ],
      isShow: false,
    };
  },
  //子组件
  components: {
    myHead,
  },
  onShow() {
    this.getJobIntention();
  },
  onLoad(option) {
    this.type = option.type;
  },
  // 计算方法
  methods: {
    clickRight(type, item) {
      //添加
      let url =
        "/pages/views/packageB/type-jobhunting/resume/edit/JobIntention";
      if (type == 2) {
        //
        item = JSON.stringify(item);
        uni.navigateTo({
          //编辑
          url: `${url}?data=${item}&type=${type}&fuid=${this.ResumeId}`,
        });
      } else {
        if (this.qiuzhiyixiangData.length >= 3) {
          this.$util.toast("最多只能添加3个求职意向~");
          return;
        }
        uni.navigateTo({
          url: `${url}?type=${type}&fuid=${this.ResumeId}`,
        });
      }
    },
    getJobIntention() {
      //获取求职意向
      this.$http.huirc.resumemy().then((res) => {
        if (res.Result) {
          if (res.Result.Id) {
            this.qiuzhiyixiangData = res.Result.JobExpects;
            this.ResumeId = res.Result.Id;
          } else {
            uni.navigateTo({
              url: "/pages/views/packageB/type-jobhunting/resume/edit/basic",
            });
          }
        } else {
          this.$util.toast("请完善基本信息");
          setTimeout(() => {
            uni.navigateTo({
              url: "/pages/views/packageB/type-jobhunting/resume/resume",
            });
          }, 1500);
        }
      });
    },
    // 删除求职意向
    handleXingqu(item) {
      this.content = `确认删除求职意向 ${item.PositionName}`;
      this.id = item.Id;
      this.show = true;
    },
    //确认删除求职意向
    confirm() {
      if (this.qiuzhiyixiangData.length > 1) {
        this.$http.huirc
          .jobexpectdel({
            Id: this.id,
          })
          .then((res) => {
            if (res.Success) {
              this.$util.toast(res.Message);
              this.getJobIntention();
            }
          });
      } else {
        this.$util.toast("至少保留一个求职意向");
      }
      this.show = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.swipeAction {
  box-sizing: border-box;
  padding: 4rpx 20rpx;
}

.jiaonliguanli {
  border-radius: 8rpx;
  background-color: #ffffff;
  margin-top: 10rpx;

  .edit_data {
    padding: 20rpx 30rpx 20rpx 26rpx;
    box-sizing: border-box;
    border-radius: 16rpx;
    background: #ffffff;
    display: flex;
    justify-content: space-between;

    .item_box {
      flex: 1;
      padding-top: 10rpx;
      margin-right: 60rpx;

      .pinfen {
        display: flex;
        justify-content: space-between !important;
        flex-direction: row;
      }

      .position {
        font-size: 30rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #000000;
      }

      .p_data {
        font-size: 30rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #000000;
      }

      .tagBox {
        margin-top: 10rpx;
        display: flex;
        flex-wrap: wrap;

        .job_type {
          padding: 8rpx 16rpx;
          font-size: 24rpx;
          font-family: PingFang SC;
          font-weight: 500;
          color: #999999;
          background: #f7f7f7;
          border-radius: 4rpx;
          margin: 16rpx 16rpx 0 0;
        }
      }
    }

    .dlsdflex {
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
}

.queshenye {
  height: calc(100vh - 88rpx + var(--status-bar-height));
  background-color: #fff;
  text-align: center;

  .queshenye-chi {
    height: 500px;
  }
}
</style>